home *** CD-ROM | disk | FTP | other *** search
/ Winzipper / Winzipper_ISO.iso / programming / oracle7 7.2 / DB / UTIL72 / ULCASE7S.SQL < prev    next >
Encoding:
Text File  |  1995-05-09  |  2.0 KB  |  66 lines

  1. Rem  Copyright (c) 1991 by Oracle Corporation
  2. Rem    NAME
  3. Rem      ulcase7s.sql - <one-line expansion of the name>
  4. Rem    DESCRIPTION
  5. Rem      <short description of component this file declares/defines>
  6. Rem    RETURNS
  7. Rem
  8. Rem    NOTES
  9. Rem      <other useful comments, qualifications, etc.>
  10. Rem    MODIFIED   (MM/DD/YY)
  11. Rem     ksudarsh   03/11/93 -  comment out vms specific host command 
  12. Rem     ksudarsh   12/30/92 -  Creation 
  13. Rem     ksudarsh   12/27/92 -  Creation
  14. Rem
  15. Rem $Header: ulcase7s.sql 7020100.1 94/09/23 22:19:22 cli Generic<base> $
  16. Rem
  17. Rem ULDEMO7S.SQL
  18. Rem   Start-script for SQL*Loader Examples, Case 7
  19.  
  20. Rem The variables the insert-trigger uses to save the last valid value
  21. Rem  are defined in a package so they will persist between calls.
  22.  
  23. Rem Since these values will be accessed by anyone inserting into EMP, only
  24. Rem  the user doing the load should have access to EMP during this time
  25. Rem  (Alternatively, the trigger could be modified to check the USERENV fnction
  26. Rem  in a WHEN clause and only perform its functions for a particular user.)
  27.  
  28. set termout off
  29. rem host write sys$output "Building Package and Trigger for Case7.Please wait"
  30. set feedback off
  31.  
  32. CREATE OR REPLACE PACKAGE uldemo7 AS
  33.     last_deptno  NUMBER;
  34.     last_job     CHAR(9);
  35.     last_mgr     NUMBER;
  36. END uldemo7;
  37. /
  38.                         
  39. CREATE OR REPLACE TRIGGER uldemo7_emp_insert
  40.   BEFORE INSERT ON emp
  41.   FOR EACH ROW
  42.  
  43.   BEGIN
  44.   IF :new.deptno IS NOT NULL THEN
  45.      uldemo7.last_deptno := :new.deptno;   -- save value for later use
  46.   ELSE
  47.      :new.deptno := uldemo7.last_deptno;   -- use last valid value
  48.   END IF;
  49.  
  50.   IF :new.job IS NOT NULL THEN
  51.      uldemo7.last_job := :new.job;   -- save value for later use
  52.   ELSE
  53.      :new.job := uldemo7.last_job;   -- use last valid value
  54.   END IF;
  55.  
  56.   IF :new.mgr IS NOT NULL THEN
  57.      uldemo7.last_mgr := :new.mgr;   -- save value for later use
  58.   ELSE
  59.      :new.mgr := uldemo7.last_mgr;   -- use last valid value
  60.   END IF;
  61.  
  62.   END;
  63. /
  64.  
  65. EXIT
  66.